package com.example.ykbboom.universitytransportation.Util;



import com.example.ykbboom.universitytransportation.MyApplication;

/**
 * Created by ykbboom on 2017/3/4 17:13
 * email：ykbpro@whut.edu.cn
 */

public class SharedPrefUtil {
    private static final String USER_NAME = "userName";
    private static final String USER_PHONE = "userPhone";
    private static final String LOGIN_STATE = "loginState";
    private static final String DRIVER_STATE = "driverState";
    private static final String USER_CITY = "userCity";
    private static final String USER_LATLONG = "userLatLong";
    private static final String DRIVER_LATLONG = "driverLatLong";
    private static final String USER_REQ_COUNT = "userReqCount";
    private static final String USER_ORDER_COUNT = "userOrderCount";
    private static final String USER_CHECK_DISTANCE = "userCheckDistance";
    private static final String TEMP_USER_CHECK_DISTANCE = "tempUserCheckDistance";

    public static void saveUserName(String userName){
        MyApplication.getEditor().putString(USER_NAME,userName).apply();
    }
    public static String getUserName(){
        return MyApplication.getSharedPreferences().getString(USER_NAME,"");
    }
    public static void saveUserPhone(String userPhone){
        MyApplication.getEditor().putString(USER_PHONE,userPhone).apply();
    }
    public static String getUserPhone(){
        return MyApplication.getSharedPreferences().getString(USER_PHONE,"");
    }
    public static void saveLoginState(Boolean b){
        MyApplication.getEditor().putBoolean(LOGIN_STATE,b).apply();
    }
    public static Boolean getLoginState(){
        return MyApplication.getSharedPreferences().getBoolean(LOGIN_STATE,false);
    }
    public static void saveDriverState(Boolean b){
        MyApplication.getEditor().putBoolean(DRIVER_STATE,b).apply();
    }
    public static Boolean getDriverState(){
        return MyApplication.getSharedPreferences().getBoolean(DRIVER_STATE,false);
    }
    public static void saveUserCity(String city){
        MyApplication.getEditor().putString(USER_CITY,city).apply();
    }
    public static String getUserCity(){return MyApplication.getSharedPreferences().getString(USER_CITY,"");}
    public static void saveUserLatlong(String latlong){
        MyApplication.getEditor().putString(USER_LATLONG,latlong).apply();
    }
    public static String getUserLatlong(){
        return MyApplication.getSharedPreferences().getString(USER_LATLONG,"");
    }
    public static void saveReqCount(Integer f){
        MyApplication.getEditor().putInt(USER_REQ_COUNT,f).apply();
    }
    public static Integer getReqCount(){
        return MyApplication.getSharedPreferences().getInt(USER_REQ_COUNT,0);
    }
    public static void saveDriverLatlong(String latlong){
        MyApplication.getEditor().putString(DRIVER_LATLONG,latlong).apply();
    }
    public static String getDriverLatlong(){
        return MyApplication.getSharedPreferences().getString(DRIVER_LATLONG,"");
    }
    public static void saveOrderCount(Integer f){
        MyApplication.getEditor().putInt(USER_ORDER_COUNT,f).apply();
    }
    public static Integer getOrderCount(){
        return MyApplication.getSharedPreferences().getInt(USER_ORDER_COUNT,0);
    }
    public static void saveCheckDistance(Integer f){
        MyApplication.getEditor().putInt(USER_CHECK_DISTANCE,f).apply();
    }
    public static Integer getCheckDistance(){
        return MyApplication.getSharedPreferences().getInt(USER_CHECK_DISTANCE,0);
    }
    public static void saveTempCheckDistance(Integer f){
        MyApplication.getEditor().putInt(TEMP_USER_CHECK_DISTANCE,f).apply();
    }
    public static Integer getTempCheckDistance(){
        return MyApplication.getSharedPreferences().getInt(TEMP_USER_CHECK_DISTANCE,0);
    }
}
